<?php
namespace app\common\model;

class ShopAttrModel extends BaseModel
{
    protected $name = 'shop_attr';
    protected $autoWriteTimestamp = false;
    // 定义自动完成的属性
    protected $auto = []; //新增修改
    protected $insert = []; //插入
    protected $update = []; //修改
    protected $type = ['attr_value'=>'json'];

    /**
     * 获取规格属性值列表
     * @param $attrIds
     * @return array|false|\PDOStatement|string|\think\Collection
     */
    public function getAttrList($attrId)
    {
        $attrInfo  = $this->get($attrId);
        $attr = [];
        foreach($attrInfo['attr_value'] as $k=>$v){
            $attr[$k]['item_name'] = $v['item_name'];
            $attr[$k]['item_list'] = explode(',',$v['item_value']);
        }
        return $attr;
    }
}
